#import "MKManager.h"
#import "MenuManager.h"
#import "GlyphView.h"
#import <appkit/ButtonCell.h>
#import <appkit/Matrix.h>
#import <stdlib.h>
#import <strings.h>

extern id Nu ;

@implementation MKManager: Object

- (double) beatsPerMinute ;
{ return [beatsPerMinuteCell doubleValue] ;
}

- beatsPerMinute: (double) beatsPerMinute ;
{ [slider setDoubleValue: beatsPerMinute] ;
  return [beatsPerMinuteCell setDoubleValue:
      beatsPerMinute] ; 
}

- setBeatsPerMinute:sender ;
{ [self beatsPerMinute: [sender doubleValue]] ;
  [[[Nu glyphView] window] setDocEdited: YES] ;
  return [[Nu glyphView] setMKMBeatsPerMinute: 
     [sender doubleValue]] ;
}

-(double )deltaT ;
{ return [deltaTCell doubleValue] ;
}

- deltaT: (double) dT ;
{ return [deltaTCell setDoubleValue: dT] ;
}

- setDeltaT: sender ;
{ [[[Nu glyphView] window] setDocEdited: YES] ;
  return [[Nu glyphView] setMKMDeltaT: 
    [sender doubleValue]] ;
}

-(BOOL) fastResponse ;
{ if([responseMatrix selectedRow] == 0)
    return NO ;
  else
    return YES ;
}

- fastResponse: (BOOL) YESorNO ;
{ if(YESorNO == YES)
    return [responseMatrix selectCellAt:1 :0] ;
  else
    return [responseMatrix selectCellAt:0 :0] ;
}

- setFastResponse: sender ;
{ [[[Nu glyphView] window] setDocEdited: YES] ;
  return [[Nu glyphView] setMKMFastResponse:
    [self fastResponse]] ;
}


-(double) headRoom ;
{ return [headRoomCell doubleValue]  ;
}

- headRoom: (double) seconds ;
{ return [headRoomCell setDoubleValue: seconds] ;
}

- setHeadRoom: sender ;
{ [[[Nu glyphView] window] setDocEdited: YES] ;
  return [[Nu glyphView] setMKMHeadRoom: 
      [sender doubleValue]] ;
}


-(double) samplingRate ;
{ if([samplingRateMatrix selectedRow] == 0)
    return 44100.0 ;
  else
    return 22500.0 ;
}

- samplingRate: (double) samplingRate ;
{ if(samplingRate == 44100.0)
    return [samplingRateMatrix selectCellAt:0 :0] ;
  else
    return [samplingRateMatrix selectCellAt:1 :0] ;
}

- setSamplingRate: sender ;
{ [[[Nu glyphView] window] setDocEdited: YES] ;
  return [[Nu glyphView] setMKMSamplingRate:
      [self samplingRate]] ;
}


-(double) tickPeriod ;
{ return [tickPeriodCell doubleValue] ;
}

- tickPeriod: (double) tickPeriod ;
{ return [tickPeriodCell setDoubleValue: tickPeriod] ;
}

- setTickPeriod: sender ;
{ [[[Nu glyphView] window] setDocEdited: YES] ;
  [[Nu glyphView] setMKMTickPeriod: [sender doubleValue]] ;
  return self ;
}

 
@end
